package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.EmployerBudget;
import cn.anxingongyou.anxin.mapper.EmployerBudgetMapper;
import cn.anxingongyou.anxin.service.EmployerBudgetService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployerBudgetServiceImpl implements EmployerBudgetService {

    private final EmployerBudgetMapper employerBudgetMapper;
    @Autowired
    public EmployerBudgetServiceImpl(EmployerBudgetMapper employerBudgetMapper) {
        this.employerBudgetMapper = employerBudgetMapper;
    }

    @Override
    public int insert(EmployerBudget employerBudget) {
        return employerBudgetMapper.insertSelective(employerBudget);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return employerBudgetMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(EmployerBudget employerBudget) {
        return employerBudgetMapper.updateByPrimaryKeySelective(employerBudget);
    }

    @Override
    public EmployerBudget selectOne(EmployerBudget employerBudget) {
        return employerBudgetMapper.selectOne(employerBudget);
    }

    @Override
    public EmployerBudget selectOneByPrimaryKey(Long id) {
        return employerBudgetMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<EmployerBudget> page(int pageNum, int pageSize, EmployerBudget employerBudget) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<EmployerBudget> list = employerBudgetMapper.select(employerBudget);
        PageInfo<EmployerBudget> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
